package com.vogue.supplymall.order.domain.mapper;

import com.vogue.supplymall.common.domain.dto.OrderDetailInfo;
import com.vogue.supplymall.common.domain.dto.SearchOrderInfo;
import com.vogue.supplymall.order.domain.model.Order;
import com.vogue.supplymall.order.domain.provider.OrderDetailSqlProvider;
import com.vogue.supplymall.order.domain.provider.OrderListSqlProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Map;

/**
 * The interface Order mapper.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-01-10
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order, Long> {

    /**
     * Find order detail list.
     *
     * @param detailInfo the detail info
     * @return the list
     * @throws RuntimeException the runtime exception
     */
    @SelectProvider(type = OrderDetailSqlProvider.class, method = "findOrderDetail")
    List<Map<String, Object>> findOrderDetail(OrderDetailInfo detailInfo) throws RuntimeException;

    /**
     * Find order  list.
     *
     * @param searchOrderInfo the search order info
     * @return the list
     * @throws RuntimeException the runtime exception
     */
    @SelectProvider(type = OrderListSqlProvider.class, method = "find")
    List<Map<String, Object>> findOrderList(SearchOrderInfo searchOrderInfo) throws RuntimeException;

    /**
     * Find order  count.
     *
     * @param searchOrderInfo the search order info
     * @return the list
     * @throws RuntimeException the runtime exception
     */
    @SelectProvider(type = OrderListSqlProvider.class, method = "findCount")
    List<Map<String, Object>> findOrderCount(SearchOrderInfo searchOrderInfo) throws RuntimeException;

    @Select("SELECT o.* FROM `order` o where o.ordernumber = #{arg0} and o.syscodeid = #{arg1} ")
    List<Order> getOrder(String ordernumber, Long syscodeid);
}
